<?php

namespace App\Models;

use App\Scopes\IsDelScope;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class PatientAddressModel extends BaseModel {

    protected static function booted()
    {
        parent::booted();
    }

    protected $table = "dtrd_ent_shc_rd_patient_address";
    protected $primaryKey = "data_id";
    // public $timestamps = false;

    const CREATED_AT = 'create_time';
    const UPDATED_AT = null;

    protected $casts = [
        'create_time' => 'datetime:Y-m-d H:i:s',
    ];

    protected $hidden = ['is_del'];
    protected $appends = ['contact_full_address'];

    protected $fillable = [
        'patient_id',
        'contact_person',
        'contact_phone',
        'contact_province_id',
        'contact_province_name',
        'contact_city_id',
        'contact_city_name',
        'contact_district_id',
        'contact_district_name',
        'contact_address',
        'is_default'
    ];

    public function getContactFullAddressAttribute()
    {
        return "{$this->contact_province_name}{$this->contact_city_name}{$this->contact_district_name}{$this->contact_address}";
    }
}
